import List from "./../../../controls/lists";
import LodgeList from "../../../controls/lists/lodge";
import HuodongList from "../../../controls/lists/huodong";
import OrgnanizeList from "./../../../controls/lists/organize";
import ActivityList from "./../../../controls/lists/activity";
import TabService from "./../../tabservice";
import {action} from "adajs";
import Page from "../../../lib/page";

class LodgeService extends TabService {
    defaultData() {
        let info = {
            tabs: [
                {
                    name: "支部信息",
                    active: true,
                    type: List,
                    option: {
                        url: "/api/lgb/app/lgb/branchinformation/queryPage",
                        type: LodgeList
                    }
                },
                {
                    "name": "支部活动", active: false, type: List, option: {
                        url: "/api/lgb/app/cms/cmsArticle/queryPage",
                        type: HuodongList,
                        parameter: {
                            siteId: "cyjlgb",
                            columnId: "BRANCHACTIVITY"
                        }
                    }
                },
                {
                    "name": "出勤情况", active: false, type: List, option: {
                        url: "/api/lgb/app/lgb/branchinformation/queryPage",
                        type: OrgnanizeList
                    }
                },
                {
                    "name": "交流互动", active: false, type: List, option: {
                        url: "/api/lgb/app/lgb/branchexchange/queryPage",
                        type: ActivityList,
                        parameter: {
                            type: "exchange",
                            t: new Date().getTime()
                        }
                    }
                }
            ],
            btns: []
        };
        this.setTabs(info.tabs);
        if (info.tabs[3].active) {
            info.btns = [{action: "addactivity", icon: ":for-add"}];
        }
        return info;
    }

    onupdate(current, data) {
        Object.assign(current, data);
    }

    @action("setTab")
    setTab(current, name) {
        Page.set(name);
        if (name === '交流互动') {
            current.btns = [{action: "addactivity", icon: ":for-add"}];
        } else {
            current.btns = [];
        }
    }

    @action("refreshList")
    refreshList(current) {
        current.tabs[3].option.parameter.t = new Date().getTime();
    }
}

export default LodgeService;